package com.tanjun.common.utils;

import com.fasterxml.jackson.core.JacksonException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;

import java.io.IOException;

public class PathDeserializer extends JsonDeserializer<String> {
    private String pre = "http://106.54.21.31:8888/public-service";

    @Override
    public String deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JacksonException {
        String value = p.getValueAsString();

        if (value.lastIndexOf(pre) > 0) {
            return value.substring(pre.length());
        }
        return value;
    }
}
